home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
program
/
355
/
source
/
flsclr
/
flsclr.mod
< prev
next >
Wrap
Text File
|
1990-02-02
|
29KB
|
990 lines
(* this is a custom file directory that was extracted from another more *)
(* extensive program I designed. The standard item selector that is in *)
(* has its limitations, one of the biggest is that it will only load in *)
(* the first 100 file names!,if you have a hard disk like me and have a *)
(* lot of source code files, then the standard item selector will not *)
(* display all your files! *)
(* If you find this you find this program useful, a donation would be *)
(* appreciated. You will discover the program is helpful to those of you*)
(* that have modula 2(TDI's Version) and want to do some programming *)
(* using the AES libraries. The Procedures have been some documentation *)
(* , but are not fully documented. If you want a more detailed explan- *)
(* ation of a particular procedure, leave a message and I'll get back *)
(* to you. *)
(* *)
(* Dan Mckee *)
(* 14A Elm St. *)
(* Mt. Home AFB, ID 83648 phone: 1-208-832-4504 *)
(* Genie - D.M. *)
(* Dephi - elmac *)
(* Compuserve - 75766,1515 *)
(* Rattle Snake BBS - 1-208-587-7603(65 meg of storage!!) *)
MODULE FileSelector;
(*$A+,$S-,$T-*)
FROM Storage IMPORT ALLOCATE,DEALLOCATE, CreateHeap;
FROM AESResources IMPORT ResourceLoad,ResourceFree,ResourceGetAddr;
FROM SYSTEM IMPORT ADDRESS,ADR,BYTE;
FROM AESForms IMPORT FormDo,FormCenter,FormAlert,FormDialogue;
FROM AESObjects IMPORT ObjectDraw,ObjectOffset,ObjectChange;
FROM AESGraphics IMPORT GrafDragBox,GrafMouseKeyboardState,GrafMouse;
FROM GEMAESbase IMPORT TEdInfo,Arrow,HourGlass,AESCallResult;
FROM BIOS IMPORT DriveMap,DriveSet,BCosStat,Device;
FROM InOut IMPORT WriteString,WriteLn,WriteCard,OpenOutputFile;
FROM GEMDOS IMPORT GetDrv,SetDrv,SFirst,SNext,SetDTA,Alloc;
FROM Strings IMPORT String,Length,Concat,Compare,CompareResults,Delete,Pos;
FROM LongInOut IMPORT WriteLongCard;
CONST
(* Resource file constances *)
tree1 = 0; (* form/dialog *)
fpath = 1; (* BOXTEXT in tree TREE1 *)
fup = 2; (* BOXTEXT in tree TREE1 *)
ftoname = 5; (* FTEXT in tree TREE1 *)
fwind = 6; (* BOX in tree TREE1 *)
fname2 = 7; (* TEXT in tree TREE1 *)
fname3 = 8; (* TEXT in tree TREE1 *)
fname4 = 9; (* TEXT in tree TREE1 *)
fname5 = 10; (* TEXT in tree TREE1 *)
fname6 = 11; (* TEXT in tree TREE1 *)
fname7 = 12; (* TEXT in tree TREE1 *)
fname8 = 13; (* TEXT in tree TREE1 *)
fname9 = 14; (* TEXT in tree TREE1 *)
fname10 = 15; (* TEXT in tree TREE1 *)
fname11 = 16; (* TEXT in tree TREE1 *)
fname12 = 17; (* TEXT in tree TREE1 *)
fname13 = 18; (* TEXT in tree TREE1 *)
fntrack = 19; (* BOX in tree TREE1 *)
fnslider = 20; (* BOX in tree TREE1 *)
drivea = 21; (* BOXTEXT in tree TREE1 *)
driveb = 22; (* BOXTEXT in tree TREE1 *)
drivec = 23; (* BOXTEXT in tree TREE1 *)
drived = 24; (* BOXTEXT in tree TREE1 *)
drivee = 25; (* BOXTEXT in tree TREE1 *)
drivef = 26; (* BOXTEXT in tree TREE1 *)
driveg = 27; (* BOXTEXT in tree TREE1 *)
driveh = 28; (* BOXTEXT in tree TREE1 *)
drivei = 29; (* BOXTEXT in tree TREE1 *)
drivej = 30; (* BOXTEXT in tree TREE1 *)
drivek = 31; (* BOXTEXT in tree TREE1 *)
drivel = 32; (* BOXTEXT in tree TREE1 *)
drivem = 33; (* BOXTEXT in tree TREE1 *)
driven = 34; (* BOXTEXT in tree TREE1 *)
driveo = 35; (* BOXTEXT in tree TREE1 *)
drivep = 36; (* BOXTEXT in tree TREE1 *)
fprint = 37; (* BOXTEXT in tree TREE1 *)
fdown = 39; (* BOXTEXT in tree TREE1 *)
exit = 38;
Normal = 0;
selected = 1;
TYPE
DirFileAttributes = (ReadWrite, WriteProt, HiddenEntry, HiddenSystem,
Volume, SubDirectory, Archive);
DirEntryPtr = POINTER TO DirEntryDef;
DirEntryDef = RECORD
Name: String;
Attr: BYTE;
Time: CARDINAL;
Date: CARDINAL;
Size: LONGCARD;
Library: DirEntryPtr;
Owner: DirEntryPtr;
Back: DirEntryPtr;
Next: DirEntryPtr;
Left: DirEntryPtr;
Right: DirEntryPtr;
END;
etree = POINTER TO TEdInfo;
objtree = RECORD
next : INTEGER;
head : INTEGER;
tail : INTEGER;
type : INTEGER;
flags : CARDINAL;
state : CARDINAL;
spec : etree;
x : CARDINAL;
y : CARDINAL;
width : CARDINAL;
height : CARDINAL;
END;
Tree = POINTER TO ARRAY[1..50] OF objtree;
objstate = (Selected);
pathrecord = RECORD
reserved : ARRAY[0..20] OF BYTE;
attrib : BYTE;
time : CARDINAL;
date : CARDINAL;
size : LONGCARD;
name : String;
END;
oned = ARRAY[1..500] OF INTEGER;
twod = ARRAY[1..500],[1..2] OF INTEGER;
VAR
tree1ptr : Tree;
handle,x,y,w,h,showit,result,oldyoff,index,fcount,th,sh,fnametemp,ii,
apid,i1,j,j1,k,p,t,i : INTEGER;
d : [0..31];
drv : DriveSet;
loaded,done,initialized,s : BOOLEAN;
drive,defaultdrive,count,ct,attr : CARDINAL;
dtarecord : pathrecord;
swidth,tswidth,ttswidth : REAL;
fn,rpath,temp,temp2 : ARRAY[0..300] OF String;
atrib : ARRAY[0..100] OF CARDINAL;
filename,match,rfarray,r1,r2,r3,r4,temp1,result2
,p1,p2,p3,p4,ffpath,ppath,Temp1,Temp2,Temp3,filearray,
globlepath,clear,ptextstr,pathstr,Path,
presult,pathdrive,
fffpath,directchr
: String;
path : ARRAY[0..300] OF String;
tsize : LONGCARD;
FreeMemory : ADDRESS;
n : oned;
s9 : twod;
PROCEDURE switch(VAR a,b: String ; VAR s1 : BOOLEAN);
VAR
t : String;
BEGIN
t := a;
a := b;
b := t;
s1 := NOT s1;
END switch;
PROCEDURE save1(VAR q : INTEGER ;VAR s8 : twod ;a ,k1 : INTEGER);
BEGIN
q := q+1;
s8[q,1] := a+1;
s8[q,2] := k1
END save1;
PROCEDURE restore(s8:twod ; VAR i2,j2,q : INTEGER);
BEGIN
i2 := s8[q,1];
j2 := s8[q,2];
q := q - 1
END restore;
PROCEDURE init(VAR a,b,a1,b1 : INTEGER ; VAR es : BOOLEAN);
BEGIN
a := a1;
b := b1;
es := FALSE;
END init;
PROCEDURE sort;
BEGIN
REPEAT
IF (Compare(path[i],path[j]) = Greater) THEN switch(path[i],path[j],s);END;
IF s THEN i := i + 1
ELSE j := j - 1;END;
UNTIL i = j;
IF NOT(i+1 >= j1) THEN save1(p,s9,i,j1);END;
j1 := i - 1;
IF i1 < j1 THEN
init(i,j,i1,j1,s);
sort;
END;
IF p <> 0 THEN
restore(s9,i1,j1,p);
init(i,j,i1,j1,s);
j := ii;
sort;
END;
END sort;
(* Load the directory into an array *)
PROCEDURE MakePath(VAR ppath : ARRAY OF CHAR);
VAR
addr : ADDRESS;
pathdrive,presult,match,directchr : String;
obspec : etree;
i2,l : INTEGER;
atrib,where,start : CARDINAL;
BEGIN
(* reset variables *)
ii := 0;
tswidth := 0.0;
ttswidth := 0.0;
(* get the current drive *)
pathdrive := CHR(ORD(defaultdrive) + ORD('A'));
Concat(pathdrive,':',presult);
(* set up the path string *)
Concat(presult,ppath,pathstr);
addr := ADR(dtarecord);
SetDTA(addr);
GrafMouse(HourGlass,NIL);
(* get the first occurance of specified path *)
SFirst(pathstr,16,result);
IF result >= 0 THEN
REPEAT
WITH dtarecord DO;
(* if the file name is not a . or .. then load in the file name *)
IF (Compare(name,'.') # Equal) AND (Compare(name,'..')
# Equal) THEN
INC(ii);
path[ii] := name;
atrib := CARDINAL(attrib);
directchr := CHR(5);
Concat(directchr," ",directchr);
(* if the file name attribute is a sub directory, add a *)
(* CHR(5) to the front of the name to indicate a folder *)
IF atrib = 16 THEN
Concat(directchr,path[ii],rpath[ii]);
ELSE
(* add a space to the beginning to the file name to keep *)
(* all the file names lined up *)
Concat(' ',path[ii],rpath[ii]);
END; (* IF atrib *)
path[ii] := rpath[ii];
(* add spaces to the end of the file name if the length is *)
(* less than 14, why? it makes the file name selecting and *)
(* deselecting visually more pleasent. *)
IF Length(rpath[ii]) < 14 THEN
FOR l := Length(rpath[ii]) + 1 TO 14 DO
Concat(rpath[ii],' ',rpath[ii]);
END; (* FOR l *)
END; (* IF Length *)
path[ii] := rpath[ii];
END; (* IF (Compare *)
END; (* WITH *)
(* limit the amount of files to 300 *)
IF ii < 300 THEN
SNext(result);
ELSE
showit := FormAlert(1,'[1][The maximum number of files|has been exceeded!][ OK ]');
result := -1;END;
UNTIL result < 0;
END; (* IF *)
match := ' ';
start := 0;
where := 0;
FOR i2 := 0 TO Length(pathstr) DO
IF Pos(pathstr,match,start,where) THEN
Delete(pathstr,where,1); END;
INC(start);
END; (* FOR *)
IF ii > 1 THEN
i1 := 1;
i := 0;
p := 0;
j1 := ii;
init(i,j,i1,j1,s);
j := ii;
(* sort the file names *)
sort;
END; (* IF ii > *)
(* find the address of the Drive Path's TEditInfo ptext *)
(* string *)
obspec := etree(tree1ptr^[fpath + 1].spec);
(* set the ptext to the current drive path *)
obspec^.ptext := ADR(pathstr);
IF initialized THEN
ObjectDraw(tree1ptr,fpath,1,x,y,w,h);END;
GrafMouse(Arrow,NIL);
END MakePath;
(* find the state of an object *)
PROCEDURE ChecktheState(tree,index : INTEGER) : BITSET;
VAR
treeaddr : Tree;
BEGIN
ResourceGetAddr(0,tree,treeaddr);
RETURN BITSET(treeaddr^[index + 1].state);
END ChecktheState;
(* get the state of an object *)
PROCEDURE GetObjectState(tree,index : INTEGER ; mask : objstate) : BOOLEAN;
TYPE
state = SET OF objstate;
VAR
value : BITSET;
treeaddr : Tree;
BEGIN
ResourceGetAddr(0,tree1,tree1ptr);
value := ChecktheState(tree,index);
RETURN (mask IN state(value));
END GetObjectState;
(* calulate the size of the file selector's slider *)
PROCEDURE CalcSliderSize;
BEGIN
(* find the height of the file selector's track *)
th := tree1ptr^[fntrack + 1].height;
(* if the number of file names is less than 12 then the slider *)
(* is the same size as the track *)
IF ii < 12 THEN
tree1ptr^[fnslider + 1].height := th;
ELSE
(* calulate the slider height, track divided by the # of files *)
swidth := FLOAT(CARDINAL(th))/FLOAT(CARDINAL(ii));
swidth := swidth * 12.0;
ttswidth := swidth;
(* ensure the slider has a minimum size *)
IF swidth < 5.00 THEN
tree1ptr^[fnslider + 1].height := 5;
swidth := swidth/12.0;
ELSE
tree1ptr^[fnslider + 1].height := INTEGER(TRUNC(swidth));
swidth := swidth/12.0;
END;
sh := tree1ptr^[fnslider + 1].height;
END; (* IF ELSE *)
tree1ptr^[fnslider + 1].y := 0;
IF initialized THEN ObjectDraw(tree1ptr,fntrack,1,x,y,w,h);END;
END CalcSliderSize;
PROCEDURE ClearSelection;
VAR
clear : String;
obspec : etree;
BEGIN
clear := '';
obspec := etree(tree1ptr^[ftoname + 1].spec);
obspec^.ptext := ADR(clear);
ObjectDraw(tree1ptr,ftoname,1,x,y,w,h);
END ClearSelection;
(* show the current path *)
PROCEDURE ShowPath(VAR ppath : ARRAY OF CHAR);
VAR
addr : ADDRESS;
pathdrive,presult,match,directchr : String;
obspec : etree;
atrib,where,start : CARDINAL;
l,i2 : INTEGER;
BEGIN
pathdrive := CHR(ORD(defaultdrive) + ORD('A'));
Concat(pathdrive,':',presult);
Concat(presult,ppath,pathstr);
match := ' ';
start := 0;
where := 0;
FOR i2 := 0 TO Length(pathstr) DO
IF Pos(pathstr,match,start,where) THEN
Delete(pathstr,where,1); END;
INC(start);
END; (* FOR *)
obspec := etree(tree1ptr^[fpath + 1].spec);
obspec^.ptext := ADR(pathstr);
IF initialized THEN
ObjectDraw(tree1ptr,fpath,1,x,y,w,h);END;
GrafMouse(Arrow,NIL);
END ShowPath;
(* display the first 12 file names in the directory *)
PROCEDURE Directory;
VAR
i : INTEGER;
obspec : etree;
BEGIN
FOR i := 1 TO 12 DO
obspec := etree(tree1ptr^[fname2 + i].spec);
obspec^.ptext := ADR(path[i]);END;
END Directory;
(* clear out the array before loading in the new path *)
PROCEDURE ClearArray;
VAR
clearstr : String;
obspec : etree;
i : INTEGER;
BEGIN
clearstr := ' ';
FOR i := 0 TO ii DO
path[i] := clearstr;
obspec := etree(tree1ptr^[fname2 + 1].spec);
obspec^.ptext := ADR(path[i]);
END; (* FOR *)
ii := 0;
tswidth := 0.0;
ttswidth := 0.0;
END ClearArray;
(* scroll down the directory one file name at a time *)
PROCEDURE ScrollDown;
VAR
obspec : etree;
i,j : INTEGER;
thestring : String;
BEGIN
ObjectChange(tree1ptr,fnametemp,0,x,y,w,h,Normal,1);
ObjectDraw(tree1ptr,fnametemp,1,x,y,w,h);
j := 0;
IF fcount < ii THEN
DEC(index,11);
FOR i := 1 TO 12 DO
obspec := etree(tree1ptr^[fname2 + i].spec);
INC(index);
obspec^.ptext := ADR(path[index]);
ObjectDraw(tree1ptr,fname2 + j,1,x,y,w,h);
INC(j);
END; (* FOR *)
INC(fcount);
tswidth := tswidth + swidth;
tree1ptr^[fnslider + 1].y := INTEGER(TRUNC(tswidth));
ObjectDraw(tree1ptr,fntrack,1,x,y,w,h);
END; (* IF *)
END ScrollDown;
(* scroll up the directory one name at a time *)
PROCEDURE ScrollUp;
VAR
i,j : INTEGER;
obspec : etree;
BEGIN
ObjectChange(tree1ptr,fnametemp,0,x,y,w,h,Normal,1);
IF fcount > 12 THEN
i := 12;
j := 0;
INC(index,11);
WHILE i # 0 DO
obspec := etree(tree1ptr^[fname2 + i].spec);
obspec^.ptext := ADR(path[index - 12]);
ObjectDraw(tree1ptr,fname13 - j,1,x,y,w,h);
DEC(i);
INC(j);
DEC(index);
END; (* WHILE *)
DEC(fcount);
tswidth := tswidth - swidth;
IF tswidth < 0.0 THEN tswidth := 0.0; END;
tree1ptr^[fnslider + 1].y := INTEGER(TRUNC(tswidth));
ObjectDraw(tree1ptr,fntrack,1,x,y,w,h);
END; (* IF *)
END ScrollUp;
(* scroll through the directory a page at a time *)
PROCEDURE Scroll12;
VAR
obspec : etree;
temp,i,mx,my,mstate,kstate,xoff,yoff : INTEGER;
thestring : String;
BEGIN
ObjectChange(tree1ptr,fnametemp,0,x,y,w,h,Normal,1);
(* find the location of the mouse *)
GrafMouseKeyboardState(mx,my,mstate,kstate);
(* find the location of the slider *)
ObjectOffset(tree1ptr,fnslider,xoff,yoff);
(* mouse coordinates are below the slider, scroll down *)
IF my > yoff THEN
IF fcount < ii THEN
temp := ii - fcount;
IF temp < 12 THEN
temp := 12 - temp;
fcount := fcount - temp;
index := index - temp;
END;
FOR i := 1 TO 12 DO
INC(fcount);
INC(index);
obspec := etree(tree1ptr^[fname2 + i].spec);
obspec^.ptext := ADR(path[index]);
tswidth := tswidth + swidth;
END; (* FOR *)
IF tswidth + FLOAT(CARDINAL(sh)) > FLOAT(CARDINAL(th)) THEN
tswidth := FLOAT(CARDINAL(th)) - ttswidth;
END;
tree1ptr^[fnslider + 1].y := INTEGER(TRUNC(tswidth));
ObjectDraw(tree1ptr,fntrack,1,x,y,w,h);
ObjectDraw(tree1ptr,fwind,2,x,y,w,h);
END;
ELSE
(* mouse coordinated are above the slider, scroll up *)
IF fcount > 12 THEN
i := 12;
IF index < 24 THEN
temp := 24 - index;
index := index + temp;
fcount := index;
END;
WHILE i <> 0 DO
obspec := etree(tree1ptr^[fname2 + i].spec);
obspec^.ptext := ADR(path[CARDINAL(index) - 12]);
tswidth := tswidth - swidth;
DEC(index);
DEC(fcount);
DEC(i);
END; (* WHILE *)
IF tswidth < 0.0 THEN tswidth := 0.0 ; END;
tree1ptr^[fnslider + 1].y := INTEGER(TRUNC(tswidth));
ObjectDraw(tree1ptr,fntrack,1,x,y,w,h);
ObjectDraw(tree1ptr,fwind,2,x,y,w,h);
END;
END;
END Scroll12;
(* find out which drive button was pressed and then set the drive *)
PROCEDURE SetTheDrive;
VAR
drvmap : LONGCARD;
obspec : etree;
path,clear : String;
BEGIN
IF GetObjectState(tree1,drivea,Selected) THEN drive := 0; END;
IF GetObjectState(tree1,driveb,Selected) THEN drive := 1; END;
IF GetObjectState(tree1,drivec,Selected) THEN drive := 2; END;
IF GetObjectState(tree1,drived,Selected) THEN drive := 3; END;
IF GetObjectState(tree1,drivee,Selected) THEN drive := 4; END;
IF GetObjectState(tree1,drivef,Selected) THEN drive := 5; END;
IF GetObjectState(tree1,driveg,Selected) THEN drive := 6; END;
IF GetObjectState(tree1,driveh,Selected) THEN drive := 7; END;
IF GetObjectState(tree1,drivei,Selected) THEN drive := 8; END;
IF GetObjectState(tree1,drivej,Selected) THEN drive := 9; END;
IF GetObjectState(tree1,drivek,Selected) THEN drive := 10; END;
IF GetObjectState(tree1,drivel,Selected) THEN drive := 11; END;
IF GetObjectState(tree1,drivem,Selected) THEN drive := 12; END;
IF GetObjectState(tree1,driven,Selected) THEN drive := 13; END;
IF GetObjectState(tree1,driveo,Selected) THEN drive := 14; END;
IF GetObjectState(tree1,drivep,Selected) THEN drive := 15; END;
GrafMouse(HourGlass,NIL);
SetDrv(drive,drvmap);
GetDrv(defaultdrive);
count := 0;
fcount := 12;
ObjectChange(tree1ptr,fnametemp,0,x,y,w,h,Normal,1);
ClearArray;
Path := '\*.*';
ShowPath(Path);
MakePath(Path);
Directory;
index := 12;
CalcSliderSize;
ObjectDraw(tree1ptr,fwind,2,x,y,w,h);
ClearSelection;
GrafMouse(Arrow,NIL);
END SetTheDrive;
PROCEDURE FirstPath;
BEGIN
Concat('\',filename,r1);
Concat(r1,'\*.*',Path);
p1 := Path;
END FirstPath;
PROCEDURE SecondPath;
BEGIN
Concat('\',filename,r2);
Concat(r1,r2,Temp1);
Concat(Temp1,'\*.*',Path);
p2 := Path;
END SecondPath;
PROCEDURE ThirdPath;
BEGIN
Concat('\',filename,r3);
Concat(Temp1,r3,Temp2);
Concat(Temp2,'\*.*',Path);
p3 := Path;
END ThirdPath;
PROCEDURE FourthPath;
BEGIN
Concat('\',filename,r4);
Concat(Temp2,r4,Temp3);
Concat(Temp3,'\*.*',Path);
p4 := Path;
END FourthPath;
(* move the file name in the directory and display it as the selected *)
(* file name *)
PROCEDURE MoveName(fname : INTEGER);
VAR
fnameobspec,selectobspec,sourceobspec,fromobspec : etree;
filenameaddr,sfilename : POINTER TO String;
fnamestr,sourcename,nothin : String;
f,p : BOOLEAN;
i,l : INTEGER;
where,start : CARDINAL;
BEGIN
fnameobspec := etree(tree1ptr^[fname + 1].spec);
filenameaddr := fnameobspec^.ptext;
filename := filenameaddr^;
match := CHR(5);
(* found a folder, open it up and display the contents *)
IF Pos(filename,match,0,where) THEN
ObjectChange(tree1ptr,fnametemp,0,x,y,w,h,Normal,1);
ObjectChange(tree1ptr,fname,0,x,y,w,h,selected,1);
IF count < 4 THEN
INC(count);END;
Delete(filename,0,2);
IF count < 5 THEN
CASE count OF
1 : FirstPath;|
2 : SecondPath;|
3 : ThirdPath;|
4 : FourthPath;
END; (* CASE *)
ClearArray;
ShowPath(Path);
MakePath(Path);
Directory;
CalcSliderSize;
index := 12;
fcount := 12;
ObjectChange(tree1ptr,fname,0,x,y,w,h,Normal,1);
ObjectDraw(tree1ptr,fname,1,x,y,w,h);
ObjectDraw(tree1ptr,fwind,2,x,y,w,h);
ClearSelection;
END;
ELSE
IF NOT Pos(filename,match,0,where) THEN
Delete(filename,0,2);
IF Pos(filename,' ',0,where) THEN
FOR l := where TO Length(filename) DO
Delete(filename,where,1);
END; (* FOR *)
END; (* IF *)
nothin := '';
IF Compare(filename,nothin) <> Equal THEN
selectobspec := etree(tree1ptr^[ftoname + 1].spec);
selectobspec^.ptext := ADR(filename);
(* draw the file name that is selected *)
ObjectDraw(tree1ptr,ftoname,1,x,y,w,h);
(* select the file name in the directory as the mouse passes *)
ObjectChange(tree1ptr,fname,0,x,y,w,h,selected,1);
(* deselect the file name in the directory as the mouse passes *)
IF fname > fnametemp THEN
ObjectChange(tree1ptr,fnametemp,0,x,y,w,h,Normal,1);END;
IF fname < fnametemp THEN
ObjectChange(tree1ptr,fnametemp,0,x,y,w,h,Normal,1);END;
fnametemp := fname;
END;
END;
END; (* IF ELSE *)
END MoveName;
(* holds the previous sub directories *)
PROCEDURE FilePath;
BEGIN
ObjectChange(tree1ptr,fnametemp,0,x,y,w,h,Normal,1);
IF count > 0 THEN
CASE count OF
1 : Path := '\*.*';
p1 := '';|
2 : Path := p1;
p2 := '';|
3 : Path := p2;
p3 := '';|
4 : Path := p3;
p4 := '';
END;
IF count >= 1 THEN
DEC(count);END;
ClearArray;
ShowPath(Path);
MakePath(Path);
Directory;
index := 12;
fcount := 12;
CalcSliderSize;
ObjectDraw(tree1ptr,fwind,2,x,y,w,h);
ClearSelection;
END;
END FilePath;
(* print a path to the printer *)
PROCEDURE PrintThePath;
VAR
result : INTEGER;
blanks,blank,rblank,astek,
rpath,path,rrpath,single,double,tsizestr,temppathstr : String;
l,i,t,atrib,where,start : CARDINAL;
BEGIN
WriteString('PATH: ');
temppathstr := pathstr;
match := ' ';
start := 0;
where := 0;
FOR i := 0 TO Length(temppathstr) DO
IF Pos(temppathstr,match,start,where) THEN
Delete(temppathstr,where,1); END;
INC(start);
END; (* FOR *)
WriteString(temppathstr);
WriteLn;
WriteLn;
REPEAT
WITH dtarecord DO
single := '.';
double := '..';
IF (Compare(name,single) # Equal) AND
(Compare(name,double) # Equal) THEN
path := name;
IF Length(path) < 13 THEN
FOR t := Length(path) TO 12 DO
Concat(rblank,' ',rblank);
END; (* FOR *)
Concat(path,rblank,rpath);
rblank := '';
END; (* IF *)
atrib := CARDINAL(attrib);
IF atrib = 16 THEN
Concat('*',rpath,rrpath);
ELSE
Concat(' ',rpath,rrpath);
END; (* IF *)
INC(ct);
WriteString(rrpath);
WriteString(' ');
WriteLongCard(size,6);
WriteString(' ');
tsize := tsize + size;
IF ct = 3 THEN
WriteLn;
ct := 0;
END;(* IF *)
END; (* IF *)
END; (* WITH *)
SNext(result);
UNTIL result < 0;
ct := 0;
WriteLn;
WriteLn;
WriteLongCard(tsize,8);
WriteString(' Bytes used in ');
WriteString(temppathstr);
WriteLn;
tsize := 0;
END PrintThePath;
PROCEDURE HardCopy;
VAR
addr : ADDRESS;
rprint : BOOLEAN;
BEGIN
SetDTA(ADR(dtarecord));
SFirst(pathstr,16,result);
rprint := BCosStat(PRT);
GrafMouse(HourGlass,NIL);
IF rprint = TRUE THEN
OpenOutputFile("PRN:");
WriteLn;
PrintThePath;
WriteLn;
OpenOutputFile("CON:");
ELSE
showit := FormAlert(1,"[1][Printer is not|responding!][ OK ]");
END; (* IF *)
GrafMouse(Arrow,NIL);
ObjectChange(tree1ptr,fprint,0,x,y,w,h,Normal,1);
END HardCopy;
(* move the slider *)
PROCEDURE MoveSlider;
VAR
i,sw,sh,tw,th,fx,fy,trackx,tracky,sliderx,slidery,
curyoff : INTEGER;
thestring : String;
obspec : etree;
count : REAL;
BEGIN
ObjectChange(tree1ptr,fnametemp,0,x,y,w,h,Normal,1);
sw := tree1ptr^[fnslider + 1].width + 1;
sh := tree1ptr^[fnslider + 1].height;
tw := tree1ptr^[fntrack + 1].width;
th := tree1ptr^[fntrack + 1].height;
ObjectOffset(tree1ptr,fntrack,trackx,tracky);
ObjectOffset(tree1ptr,fnslider,sliderx,slidery);
GrafDragBox(sw,sh,sliderx,slidery,trackx,tracky,tw,th,fx,fy);
tree1ptr^[fnslider + 1].y := fy - tracky;
ObjectDraw(tree1ptr,fntrack,1,x,y,w,h);
count := FLOAT(CARDINAL(fy - tracky)) / swidth;
index := INTEGER(TRUNC(count));
fcount := index;
curyoff := tree1ptr^[fnslider + 1].y;
tswidth := count * swidth;
FOR i := 1 TO 12 DO
INC(fcount);
INC(index);
obspec := etree(tree1ptr^[fname2 + i].spec);
obspec^.ptext := ADR(path[index]);
END; (* FOR *)
ObjectDraw(tree1ptr,fwind,1,x,y,w,h);
END MoveSlider;
(* load the resource file *)
PROCEDURE LoadResource;
CONST
RFilename = ':\FLSCLR.RSC';
VAR
rname,pathdrive,path : String;
BEGIN
GetDrv(defaultdrive);
pathdrive := CHR(ORD(defaultdrive) + ORD('A'));
rname := RFilename;
Concat(pathdrive,rname,path);
ResourceLoad(path);
IF AESCallResult = 0 THEN
loaded := FALSE; ELSE loaded := TRUE; END;
END LoadResource;
(* initalize the program *)
PROCEDURE Initialize;
VAR
fromobspec : etree;
path,blank : String;
drivemap : LONGCARD;
BEGIN
blank := '';
fcount := 12;
ResourceGetAddr(0,tree1,tree1ptr);
initialized := FALSE;
GetDrv(defaultdrive);
SetDrv(defaultdrive,drivemap);
drv := DriveMap();
FOR d := 0 TO 15 DO
IF d IN drv THEN
ObjectChange(tree1ptr,drivea + d,0,x,y,w,h,Normal,0);END;
END; (* FOR *)
ObjectChange(tree1ptr,drivea + INTEGER(defaultdrive),0,x,y,w,h,selected,0);
fnametemp := fname2;
path := '\*.*';
MakePath(path);
ShowPath(path);
Directory;
fromobspec := etree(tree1ptr^[ftoname + 1].spec);
fromobspec^.ptext := ADR(blank);
CalcSliderSize;
initialized := TRUE;
index := 12;
IF NOT CreateHeap(256 * 1024,TRUE) THEN HALT;END;
END Initialize;
(* the event loop *)
PROCEDURE EventLoop;
BEGIN
FormCenter(tree1ptr,x,y,w,h);
FormDialogue(0,0,0,0,0,x,y,w,h);
FormDialogue(1,0,0,0,0,x,y,w,h);
ObjectDraw(tree1ptr,0,2,x,y,w,h);
GrafMouse(Arrow,NIL);
REPEAT
showit := FormDo(tree1ptr,ftoname);
CASE showit OF
fup : ScrollUp;|
fdown : ScrollDown;|
fname2..fname13 : MoveName(showit);|
fpath : FilePath;|
fprint : HardCopy;|
fnslider : MoveSlider;|
fntrack : Scroll12;|
drivea..drivep : SetTheDrive;|
END; (* CASE *)
UNTIL GetObjectState(tree1,exit,Selected);
FormDialogue(2,0,0,0,0,x,y,w,h);
FormDialogue(3,0,0,0,0,x,y,w,h);
END EventLoop;
BEGIN (* MAIN PROGRAM *)
LoadResource;
IF loaded THEN
Initialize;
EventLoop;
ResourceFree;
ELSE
showit := FormAlert(0,"[1][Resource file not found!][ OK ]");END;
END FileSelector.